package com.hmily.dubbo.provider.spi.aop.impl;

import com.hmily.dubbo.provider.spi.aop.NameService;

/**
 * <h1>Redis服务Wrapper类。</h1>
 *
 * @author hmilyylimh
 * ^_^
 * @version 0.0.1
 * ^_^
 * @date 2021-11-14
 */
public class RedisServiceWrapper implements NameService {

    private NameService nameService;

    /**
     * <h2>这里通过使用参数的构造方法来达到使用 aop 的效果。</h2>
     *
     * @param nameService
     */
    public RedisServiceWrapper(NameService nameService) {
        this.nameService = nameService;
    }

    @Override
    public String getName(String name) {
        String preMsg = "[RedisServiceWrapper--pre]\r\n";

        String result = nameService.getName(name);

        String postMsg = "\r\n[RedisServiceWrapper--post]\r\n";

        return preMsg + result + postMsg;
    }
}
